Page({
  data: {
    title: '参数设置',
    editable: true,
    pingmuchangliang: "cloud://tfjkp-0ge80vu9ea710148.7466-tfjkp-0ge80vu9ea710148-1305195523/myjkp/myProfilePage/icon/parameterIcon/pingmuchangliang.png",
    shoujizhendong: "cloud://tfjkp-0ge80vu9ea710148.7466-tfjkp-0ge80vu9ea710148-1305195523/myjkp/myProfilePage/icon/parameterIcon/shoujizhendong.png",
    houtaidingwei: "cloud://tfjkp-0ge80vu9ea710148.7466-tfjkp-0ge80vu9ea710148-1305195523/myjkp/myProfilePage/icon/parameterIcon/houtaidingwei.png",
    screenAlwaysOn: false,  // 屏幕常亮初始状态
    phoneVibration: false,  // 手机振动初始状态
    backgroundLocation: false, // 后台定位初始状态
    keepScreenOn: false,
    vibrate: false,
    hiddenmodalput: true,
  },

  // 通用开关事件处理函数
  // onSwitchChange(e) {
  //   const switchType = e.currentTarget.dataset.switchType; // 获取切换的开关类型
  //   this.setData({
  //     [switchType]: e.detail.value // 更新对应开关的状态
  //   });
  // },
  keepScreenOnSwitch() {
    if (this.data.vibrate) {
      wx.vibrateShort({})
    }
    this.setData({
      keepScreenOn: !this.data.keepScreenOn
    });
    wx.setKeepScreenOn({
      keepScreenOn: this.data.keepScreenOn
    });
  },
  vibrateSwitch() {
    if (!this.data.vibrate) {
      wx.vibrateShort({})
    }
    this.setData({
      vibrate: !this.data.vibrate
    });
  },


  clearStorage(){
    if (this.data.vibrate) {
      wx.vibrateShort({})
    }
    wx.showModal({
      title: '提示',
      content: '确定要清空数据?清空后将无法撤回!',
      success(res){
        if(res.confirm){
          wx.clearStorage({
            complete: (res) => {
              wx.showToast({
                title: '清空成功',
                icon: 'success'
              })
            },
          })
        }else{
          wx.showToast({
            title: '取消清空'
          })
        }
      }
    })
  },
  modalinput: function () {
    this.setData({
      //注意到模态框的取消按钮也是绑定的这个函数，
      //所以这里直接取反hiddenmodalput，也是没有毛病
      hiddenmodalput: !this.data.hiddenmodalput
    })
  },
  confirm4StuId:function(){
    
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
   
    this.setData({
      vibrate: wx.getStorageSync('vibrate'),
      keepScreenOn: wx.getStorageSync('keepScreenOn')
    });
  },
  settingMenu() {
    wx.openSetting({})
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
   
    wx.setStorageSync('vibrate', this.data.vibrate);
    wx.setStorageSync('keepScreenOn', this.data.keepScreenOn);
  
  },

  /** 
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})
